@rem/ $Id: firefox2ie.bat 99 2008-01-16 15:51:11Z honghunter $

@echo off & color 02 & setlocal enabledelayedexpansion

@rem/ init
set temp_path_last=1
set "bookmark_file=bookmarks_ansi.html"
set "temp_bat=tmp.bat"
set "temp_path_bat=tmpPath.bat"
set "temp_ie_bat=tmpIE.bat"
echo/>%temp_bat%
echo/>%temp_path_bat%

call getFFP_home.bat
call getIE_home.bat
echo set "IE_Fav=%IE_Fav%">%temp_ie_bat%
if exist "%bookmark_file%" del /q/s "%bookmark_file%" >nul
call U82GB.vbs "%ffFav_file%" "%bookmark_file%"

for /f "delims=<> tokens=1-5" %%a in ('findstr /i "<DT><H3[^>]*>.*</H3> <DT><A[^>]*>.*</A>" %bookmark_file%') do (
@rem/		echo a=%%a;b=%%b;c=%%c;d=%%d;e=%%e;
    if /i "%%e"=="/H3" (call:sub_fix_path "#%%a#" %%d)
    if /i "%%e"=="/A" (
        (for /f "usebackq tokens=2" %%a in ('%%c') do (
            set mystr=%%a
            set temp_url=!mystr:~5!
            echo set url=!mystr:~5!>>%temp_bat%
        )) 2>nul
        echo set notes="%%d">>%temp_bat%
        call mkshotcut.bat
        echo/>%temp_bat%        
    )
)
endlocal
@rem/ pause

del /q/s %temp_bat% >nul
del /q/s %temp_path_bat% >nul
del /q/s %temp_ie_bat% >nul

goto :eof


:sub_fix_path

	set temp_path=%~1
	set temp_path_name=%2

	if "%temp_path%"=="#    #" set temp_path=1
	if "%temp_path%"=="#        #" set temp_path=2
	if "%temp_path%"=="#            #" set temp_path=3
	if "%temp_path%"=="#                #" set temp_path=4
	if "%temp_path%"=="#                    #" set temp_path=5
	if "%temp_path%"=="#                        #" set temp_path=6
	
  set "tmp_dir%temp_path%=%temp_path_name%\\"
  
  if %temp_path% EQU 1 ( set "tmp_dir2=" & set "tmp_dir3=" & set "tmp_dir4=" & set "tmp_dir5=" )
  if %temp_path% EQU 2 ( set "tmp_dir3=" & set "tmp_dir4=" & set "tmp_dir5=" )
  if %temp_path% EQU 3 ( set "tmp_dir4=" & set "tmp_dir5=" )
  if %temp_path% EQU 4 ( set "tmp_dir5=" )
  
  set temp_path_full=%tmp_dir1%%tmp_dir2%%tmp_dir3%%tmp_dir4%%tmp_dir5%  
  set temp_path_last=%temp_path%

:intercept
	if "%temp_path_full:~-1%"==" " set "temp_path_full=%temp_path_full:~0,-1%"&goto intercept

  echo set target_path="%temp_path_full%">%temp_path_bat%
  echo set target_path="%temp_path_full%">>%temp_bat%

goto :eof

